﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace CalendarApplication
{
    public partial class ucDayTemplate : UserControl
    {
        DateTime d;
        ucCalendarContainer _cal;

        public ucDayTemplate(DateTime ThisDay, ucCalendarContainer Cal)
        {
            //local variables holding a datetime and the calendar user control
            d = ThisDay;
            _cal = Cal;

            InitializeComponent();

            //updating label in square
            lklbDay.Text = ThisDay.Day.ToString();

            //connection to database and pulls information to day square
            //TODO this needs to be abstracted into service/datalayer
            //Commented below to work until SQL Server installed
            
            //SqlConnection conn = new SqlConnection(Utilities.DBConnection);
            //conn.Open();
            ////selecting information from DB about this date and putting this information into a datagrid view
            //SqlCommand sc = new SqlCommand("SELECT * FROM tblCalendarMain WHERE Date='" + d + "'", conn);
            //sc.CommandType = CommandType.Text;
            //SqlDataAdapter da = new SqlDataAdapter(sc);
            //DataTable dt = new DataTable();
            //da.SelectCommand = sc;
            //da.Fill(dt);

            ////datatable into datagridview

            //dataGridView1.DataSource = dt;
            //dataGridView1.Columns["pkID"].Visible = false;
            //dataGridView1.Columns["Date"].Visible = false;
            //dataGridView1.Columns["EndTime"].Visible = false;
            //conn.Close();
            //conn.Dispose(); 
        }

        private void lklbDay_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //show a details form when clicked
            frmDayDetails frm = new frmDayDetails(d, _cal);
            frm.ShowDialog();
        }
    }
}
